Skip to content

Comments

Robust member count synchronization#80

Merged
sergeychernyshev merged 2 commits intomainfrom
78-when-updating-system-catalog-for-the-number-of-members-in-the-account-select-the-count-from-the-accountdo-sqlite-members-table-rather-than-just-incrementingdecrementing
Feb 22, 2026
Merged

Robust member count synchronization#80
sergeychernyshev merged 2 commits intomainfrom
78-when-updating-system-catalog-for-the-number-of-members-in-the-account-select-the-count-from-the-accountdo-sqlite-members-table-rather-than-just-incrementingdecrementing

Conversation

@sergeychernyshev
Copy link
Member

@sergeychernyshev sergeychernyshev commented Feb 22, 2026

This PR improves how the member count is synchronized between AccountDO and the SystemDO index.

Previously, the system used incrementMemberCount and decrementMemberCount operations in SystemDO, which could potentially get out of sync if updates failed or were skipped.

Changes:

  • Replaced incrementMemberCount and decrementMemberCount in SystemDO with a single updateMemberCount(accountId, count) method.
  • Implemented syncMemberCount in AccountDO which performs an actual SELECT COUNT(*) on its local members table to get the source of truth.
  • Updated addMember and removeMember in AccountDO to use this new synchronization logic.
  • Added a regression test in test/admin.spec.ts that demonstrates the system's ability to restore a corrupted member count in SystemDO using the AccountDO source of truth.

Closes #78

✨ Assisted by AI: Gemini

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 22, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
startup-api 94f047b Feb 22 2026, 11:20 PM

@sergeychernyshev sergeychernyshev merged commit 8c628f5 into main Feb 22, 2026
2 checks passed
@sergeychernyshev sergeychernyshev deleted the 78-when-updating-system-catalog-for-the-number-of-members-in-the-account-select-the-count-from-the-accountdo-sqlite-members-table-rather-than-just-incrementingdecrementing branch February 22, 2026 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant